#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct BTNode
{
    char data;
    struct BTNode* left;
    struct BTNode* right;
}BTNode;

BTNode* BuyNode(char x)
{
    BTNode* newnode = (BTNode*)malloc(sizeof(BTNode));
    newnode->data = x;
    newnode->left = newnode->right = NULL;
    return newnode;
}

BTNode* CreatTree(char* arr, int* i)
{
    if (arr[*i] == '#')
    {
        (*i)++;
        return NULL;
    }
    BTNode* node = BuyNode(arr[*i]);
    (*i)++;
    node->left = CreatTree(arr, i);
    node->right = CreatTree(arr, i);
    return node;
}

void BTTreeInOrder(BTNode* root)
{
    if (root == NULL)
    {
        return;
    }
    BTTreeInOrder(root->left);
    printf("%c ", root->data);
    BTTreeInOrder(root->right);
}

int main()
{
    char arr[101] = { 0 };
    scanf("%s", arr);
    int i = 0;
    BTNode* tree = CreatTree(arr, &i);
    BTTreeInOrder(tree);
    return 0;
}